package sea.simulate;

import sea.util.PublicParam;
import sea.util.SimHyAHelper;
import sea.util.WinHelper;


/**
 *
 * This class builds the layout of Advanced Interface of Simulate
 * 
 * @author  Zhirun Ding
 * 
 * Created on 05/07/2012
 * 
 */

public class SimulateHAdvancedForm extends javax.swing.JDialog {
    
    /** Creates new form SimulateHAdvancedForm */
    public SimulateHAdvancedForm(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        usecacheCheckBox = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        verbosityLeveComboBox = new javax.swing.JComboBox();
        backButton = new javax.swing.JButton();
        helpButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sea.SimHyAGui.class).getContext().getResourceMap(SimulateHAdvancedForm.class);
        setTitle(resourceMap.getString("SimulateHAdvancedForm.title")); // NOI18N
        setName("SimulateHAdvancedForm"); // NOI18N
        setResizable(false);

        usecacheCheckBox.setText(resourceMap.getString("usecacheCheckBox.text")); // NOI18N
        usecacheCheckBox.setToolTipText(resourceMap.getString("usecacheCheckBox.toolTipText")); // NOI18N
        usecacheCheckBox.setName("usecacheCheckBox"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        verbosityLeveComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0(no info)", "1(some)", "2(diag)" }));
        verbosityLeveComboBox.setSelectedIndex(1);
        verbosityLeveComboBox.setName("verbosityLeveComboBox"); // NOI18N

        backButton.setText(resourceMap.getString("backButton.text")); // NOI18N
        backButton.setName("backButton"); // NOI18N
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        helpButton.setText(resourceMap.getString("helpButton.text")); // NOI18N
        helpButton.setName("helpButton"); // NOI18N
        helpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(verbosityLeveComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(usecacheCheckBox))
                .addContainerGap(129, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(233, Short.MAX_VALUE)
                .addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(helpButton)
                .addGap(23, 23, 23))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(usecacheCheckBox)
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(verbosityLeveComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(backButton)
                    .addComponent(helpButton))
                .addContainerGap(43, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        //generate simulate command
        toSimulateCommand();
        
        //close this form
        this.dispose();
    }//GEN-LAST:event_backButtonActionPerformed

    private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed
        WinHelper.showHelp("simulate/usecache");
    }//GEN-LAST:event_helpButtonActionPerformed
    
    void toSimulateCommand() {
        String s = "";
        //use cache
        if (usecacheCheckBox.isSelected()) {
            s = ",usecache";
        }
        
        //Verbosity Level
//        try {
//            if (verbosityLeveComboBox.getSelectedIndex() >= 0) {
//                s += ",verbose=" + verbosityLeveComboBox.getSelectedIndex();
//            }
//        } catch(Exception ex) {            
//        }
        
        PublicParam.TempSimHyACommandExpression1 = s;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                SimulateHAdvancedForm dialog = new SimulateHAdvancedForm(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JButton helpButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JCheckBox usecacheCheckBox;
    private javax.swing.JComboBox verbosityLeveComboBox;
    // End of variables declaration//GEN-END:variables
    
}
